﻿using Microsoft.AspNetCore.DataProtection.KeyManagement;
using bpms.Dao;
using bpms.Models;

namespace bpms.Service
{
    /// <summary>
    /// 文具商品服务类
    /// </summary>
    public class ProductService
    {

        private readonly ProductDao productDao;
        public ProductService(ProductDao dao)
        {
            productDao = dao;
        }

        /// <summary>
        /// 根据商品编号或者名称查询饮品列表
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public List<Product> GetList(string key)
        {
            return productDao.GetList(key);
        }

        /// <summary>
        /// 添加商品
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public int Add(Product product)
        {
            return productDao.Add(product);
        }

        /// <summary>
        /// 修改商品
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public int Update(Product product)
        {
            return productDao.Update(product);
        }

        /// <summary>
        /// 根据Id获取商品
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Product GetById(int id)
        {
            return productDao.GetById(id);
        }

        /// <summary>
        /// 删除商品
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int Delete(int id)
        {
            return productDao.Delete(id);
        }

        /// <summary>
        /// 商品上架和下架
        /// </summary>
        /// <param name="id"></param>
        /// <param name="tuijianUserId"></param>
        /// <param name="reason"></param>
        /// <returns></returns>
        public int UpOrDown(int id, int status)
        {
            return productDao.UpOrDown(id, status);
        }

    }
}
